var oLoginBox = document.getElementsByClassName('main')[0].getElementsByClassName('login')[0];
var oUserBox = document.getElementsByClassName('main')[0].getElementsByClassName('user')[0];
var oImg = oUserBox.getElementsByTagName('img')[0];
var out = oUserBox.getElementsByClassName('outbtn')[0];


//检查登录转换头像 
//检查网页本地 是否有登录成功的信息
async function check() {
    let token = localStorage.getItem('token');
    if (token) {
        oLoginBox.style.display = 'none';
        oUserBox.style.display = 'inline-block';
        let [, { result: [{ head_photo_url }] }] = await myajax({
            url: '/api/usercenter',
        })
        if (head_photo_url) {
            oImg.src = head_photo_url;
        }
    }
}
check();

//退出登录
$('.outbtn').click (function () {
    localStorage.removeItem('token');
    location.reload();
})